import QtQuick 2.2
import QtQuick.Window 2.1

Window {
    visible: true
    width: 360
    height: 360

    Rectangle {
        anchors.fill: parent;

        Text {
            id: moveText;
            anchors.centerIn: parent;
            text: "Hello QtQuick";
            font {
                pixelSize: 40;
                family: "微软雅黑";
                weight: Font.Light;
            }
            color: "skyblue";
        }

        focus: true;
        Keys.onPressed: {
            moveText.anchors.centerIn = undefined;
            var step = 20;
            switch(event.key){
            case Qt.Key_W:
                moveText.y -= step;
                break;
            case Qt.Key_S:
                moveText.y += step
                break;
            case Qt.Key_D:
                moveText.x += step;
                break;
            case Qt.Key_A:
                moveText.x -= step;
                break;
            default:
                break;
            }
        }
    }
}
